package com.example.lenovo.myapplication;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class Main2Activity extends AppCompatActivity implements View.OnClickListener {
    private Button btn_login;
    private Button btn_register;
    private EditText editText_uname;
    private EditText editText_password;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);

        btn_login=(Button)findViewById( R.id.login_button_log);
        btn_register=(Button)findViewById( R.id.login_button_register);

        editText_uname=(EditText)findViewById( R.id.login_edittext_uname);
        editText_password=(EditText)findViewById( R.id.login_edittext_password);
//        //按钮设置添加点击事件
        btn_login.setOnClickListener(this);
        btn_register.setOnClickListener(this);
    }

    @Override
    public void onClick (View v) {
        switch (v.getId()) {
            case R.id.login_button_log:
                String uname=editText_uname.getText().toString();
                String password=editText_password.getText().toString();
                if(uname.isEmpty() || password.isEmpty()) {
                    //提示语
                    Toast.makeText(this, "内容不能为空", Toast.LENGTH_LONG).show();
                }else{
                    startActivity(new Intent(this,layoutActivity.class));
                }
                break;

            case R.id.login_button_register:
                startActivity(new Intent(this,registerActivity.class));
                break;
        }
    }


}

